#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,i,mile,m;
	cin>>n>>k;
	char id[19];
	map<string,int>vip;
	map<string,int>::iterator iter;
	for(i=0;i<n;i++)
	{
		scanf("%s",id);
		scanf("%d",&mile);
		iter=vip.find(id);
		if(iter!=vip.end())
		{
		if(mile>k)
		vip[id]=iter->second+mile;
		else
		vip[id]=iter->second+k;
		}
		else
		{
			if(mile>k)
			vip[id]=mile;
			else
			vip[id]=k;
		}
		
	}
	cin>>m;
	for(i=0;i<m;i++)
	{
		scanf("%s",id);
		iter=vip.find(id);
		if(iter!=vip.end() )
		{
			cout<<iter->second<<"\n";
		}
		else
		cout<<"No Info\n";
	}
}
